-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fixed float parsing with unit when using pd.to_datetime (GH13834) #13847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Current coverage is 85.30% (diff: 100%)@@ master #13847 diff @@
==========================================
Files 139 139
Lines 50157 50157
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
- Hits 42785 42784 -1
- Misses 7372 7373 +1
Partials 0 0
|
@@ -855,3 +855,5 @@ Bug Fixes | |||
|
|||
- Bug in ``.to_excel()`` when DataFrame contains a MultiIndex which contains a label with a NaN value (:issue:`13511`) | |||
- Bug in ``pd.read_csv`` in Python 2.x with non-UTF8 encoded, multi-character separated data (:issue:`3404`) | |||
|
|||
- Bug in ``pd.to_datetime()`` did not cast floats correctly, resulting in truncated datetime (:issue:`13845`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -2095,7 +2095,7 @@ cpdef array_with_unit_to_datetime(ndarray values, unit, errors='coerce'): | |||
# if we have nulls that are not type-compat | |||
# then need to iterate | |||
try: | |||
iresult = values.astype('i8') | |||
iresult = values.astype('i8', casting='no') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should actually be casting='same_kind'
. You can also add copy=False
to avoid a copy in the case where the values are already int64.
In [35]: a = np.array([1, 2, 3], dtype='int32')
In [36]: a.astype('int64', casting='no')
TypeError Traceback (most recent call last)
<ipython-input-36-efb09bba64c8> in <module>()
----> 1 a.astype('int64', casting='no')
TypeError: Cannot cast array from dtype('int32') to dtype('int64') according to the rule 'no'
In [37]: a.astype('int64', casting='same_kind')
Out[37]: array([1, 2, 3], dtype=int64)
Having trouble w/ my laptop recently, so sorry for slow response. Please lmk if there's anything else, I will try to fix anything asap. Thanks for the suggestion @chris-b1 |
@jreback everything good here? |
@@ -972,3 +972,5 @@ Bug Fixes | |||
|
|||
- Bug in ``Index`` raises ``KeyError`` displaying incorrect column when column is not in the df and columns contains duplicate values (:issue:`13822`) | |||
- Bug in ``Period`` and ``PeriodIndex`` creating wrong dates when frequency has combined offset aliases (:issue:`13874`) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be much more explict here, this is only when unit
specified.
lgtm. ping when fixed / green. |
just about to merge this and I saw:
|
git diff upstream/master | flake8 --diff